local xishi = fk.CreateSkill{
  name = "plum__xishi",
}

Fk:loadTranslationTable{
  [xishi.name] = "析势",
  [":"..xishi.name] = "若你正面朝上，你至其他角色距离-X且使用【杀】目标上限+X（X为背面向上角色数）；若你背面向上，你拥有“威驻”。",
}

xishi:addEffect(fk.TurnedOver, {
  can_refresh = function (self, event, target, player, data)
    return player == target and player:hasSkill(xishi.name)
  end,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    room:handleAddLoseSkills(player, (player.faceup and "-" or "") .. "plum__weizhu")
  end
})

xishi:addEffect("distance", {
  correct_func = function (self, from, to)
    if from:hasSkill(xishi.name) and from.faceup then
      local n = #table.filter(Fk:currentRoom().alive_players, function (p) return not p.faceup end)
      return -n
    end
  end
})

xishi:addEffect("targetmod", {
  extra_target_func = function (self, player, skill, card)
    if player:hasSkill(xishi.name) and player.faceup and skill.trueName == "slash_skill" then
      local n = #table.filter(Fk:currentRoom().alive_players, function (p) return not p.faceup end)
      return n
    end
  end
})

return xishi
